package com.kili.file.enums;

import org.springframework.http.MediaType;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Gordon
 * @version 2019/4/1
 */
public enum FileContentType {

    TXT("txt", MediaType.TEXT_PLAIN_VALUE),
    APK("apk", "application/vnd.android.package-archive"),
    CSS("css", "text/css"),
    HTML("html", MediaType.TEXT_HTML_VALUE),
    DOC("doc", "application/msword"),
    DOCX("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"),
    PDF("pdf", MediaType.APPLICATION_PDF_VALUE),
    XLS("xls", "application/vnd.ms-excel"),
    XLSX("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
    PS("ps", "application/x-ps"),
    RTF("rtf", "application/x-rtf"),
    ZIP("zip","application/zip"),
    JPG("jpg", MediaType.IMAGE_JPEG_VALUE),
    PNG("png", MediaType.IMAGE_PNG_VALUE),
    GIF("gif", MediaType.IMAGE_GIF_VALUE);
    private String type;
    private String contentType;

    FileContentType(String type, String contentType) {
        this.type = type;
        this.contentType = contentType;
    }

    public static final Map<String, String> FILE_CONTENT_TYPE_MAP = new HashMap<>();

    static {
        FileContentType[] var1 = values();
        Arrays.asList(var1).forEach((var2) ->
                FILE_CONTENT_TYPE_MAP.put(var2.type, var2.contentType)
        );
    }
}
